// pages/moban_doc/moban_doc.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    img:[
        "https://shy.xihenet.net/uploads/tempimg/35-0.jpg",
        "https://shy.xihenet.net/uploads/tempimg/40-0.jpg"
    ],
    img1:[]
  },
  onChange(e) {
    console.log(e.detail)
  },
  onScale(e) {
    console.log(e.detail)
  },
  onChange1(e) {
    console.log(e.detail)
  },
  onScale1(e) {
    console.log(e.detail)
  },
  // 对应js中bindtap函数的代码
  tianxie_xx:function(e){
    var mb_id = e.currentTarget.dataset.id; 
    if(app.globalData.sm_qy==0){
      wx.showModal({
        title: '',
        content: '请先完善企业认证!',
        showCancel: false,
        success:function(res){
              if(res.confirm){
                 wx.navigateTo({
                   url: '../qy_rz/qy_rz',
                 })
              }else{
                 
              }
        }
      })
    }else if(app.globalData.sm_rz==0){
      wx.showModal({
        title: '',
        content: '请先完善实名认证!',
        showCancel: false,
        success:function(res){
              if(res.confirm){
                 wx.navigateTo({
                   url: '../shimingrenzheng/shimingrenzheng',
                 })
              }else{
                 
              }
        }
      })
    }else{
      wx.navigateTo({
        url: '../tianxie_xx/tianxie_xx?mb_id='+mb_id,
      })
    }
    
  },
 // 设置
 previewImage(e) {
  var that = this;
  var cur = e.target.dataset.src; //获取本地一张图片链接
  var id =  e.target.dataset.id;
  console.log(cur)
  wx.previewImage({
    current: this.data.img1[id], //字符串，默认显示urls的第一张
    urls: this.data.img1 // 数组，需要预览的图片链接列表
    // current: cur,
    // urls:[cur]
  })

},
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    var mb_id = options.mb_id
    console.log(mb_id)
    that.setData({
      img:this.data.img
    })

    wx.request({
      url: app.globalData.url_l + 'api/order/muban',
      method: 'post',
      data:{
        mb_id:mb_id
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res)
        app.globalData.images = res.data.muban
        that.setData({
            tu_img:res.data,
            img1:res.data.muban
        })
      }
    })


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    if(app.globalData.sc==2){
      wx.showModal({
        title: '温馨提示',
        content:app.globalData.sc_ts,
        success (res) {
          if (res.confirm) {
            wx.switchTab({
              url: '../index/index',
            })
          } else if (res.cancel) {
            wx.switchTab({
              url: '../index/index',
            })
          }
        }
      })
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})